home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / examples / listbox.c < prev    next >
C/C++ Source or Header  |  1994-03-13  |  780b  |  43 lines

  1. /*
  2. ** LISTBOX.C: Lets the user select from a list of items.
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <pictor.h>
  7.  
  8. #define NUM_ITEMS    7
  9. char *items[NUM_ITEMS] = {
  10.    "Apples",
  11.    "Bananas",
  12.    "Carrots",
  13.    "Grapes",
  14.    "Kiwi",
  15.    "Raisins",
  16.    "Watermelon",
  17. };
  18.  
  19. COLORSTRUCT colors = {
  20.    foreback(BOLD+CYAN,BLUE),
  21.    foreback(BOLD+WHITE,CYAN),
  22.    foreback(BLACK,WHITE),
  23.    foreback(BOLD+WHITE,WHITE)
  24. };
  25.  
  26. void main()
  27. {
  28.    char buffer[45];
  29.    int sel = 0;
  30.  
  31.    /* initialize the library */
  32.    initvideo();
  33.  
  34.    if(listbox(items,NUM_ITEMS,&sel,"Fruit",&colors)) {
  35.       sprintf(buffer,"You selected %s",items[sel]);
  36.       messagebox(buffer,NULL,MB_OK,&colors);
  37.    }
  38.    else {
  39.       messagebox("You pressed <Escape>",NULL,MB_OK,
  40.          &colors);
  41.    }
  42. }
  43.